package com.igeek.base.ch0711.Dome3;

/**
 * @Description TODO
 * @Author chenmin
 * @Date 2024/7/11 19:17
 */
public class Person {
    private String name;
    private int age;
    private boolean gender;
    private Person partner;

    public Person(String name, int age, boolean gender, Person partner) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.partner = partner;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public boolean isGender() {
        return gender;
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }

    public Person getPartner() {
        return partner;
    }

    public void setPartner(Person partner) {
        this.partner = partner;
    }

    public void marry(Person p){
        if (gender==p.gender){
            System.out.println("不能结婚，因为同性");
        }else if (gender==true&&age<24||p.gender==false&&p.age<22){
            System.out.println("不能结婚，因为未达到结婚年龄");
        } else if (partner!=null||p.partner!=null) {
            System.out.println("不能结婚，因为某一方已婚");
        }else {
            System.out.println("可以结婚,恭喜"+name+(gender?"男士":"女士")+"和"+p.name+(p.gender?"男士":"女士")+"新婚大吉！");
        }

    }
}
